package com.cty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

//测试电子邮件是否合法
public class Test04 {
    public static void main(String[] args) {
        String content = "455546522@qq.com";
        String regStr = "[\\w-]+@([a-zA-Z]+\\.)+[a-zA-Z]+";
        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        if (matcher.find()) {
            System.out.println("该电子邮件合法");
        }else{
            System.out.println("该电子邮件不合法");
        }
    }
}